package com.ra.landlord;

import java.text.SimpleDateFormat;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.googlecode.cswish.annotation.Rest;
import com.googlecode.cswish.struts.spring.GenericService;

@Service
public class LandlordTracerService {
	
	@Resource
	private LandlordUserService landlordUserService;
	
	@Resource
	private GenericService genericService;
	
	@Rest(simpleServiceName="loginUser",type="free")
	public String getLastLoginTime(){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date="";
		LandlordTracer model=new LandlordTracer();
		model.setLandlordUser(landlordUserService.getLoginUser());
		List list=genericService.search(model,0,0,"id","desc",false).getData();
		if(list.size()>0&&((LandlordTracer)list.get(0)).getLastLoginTime()!=null){
			date=sdf.format(((LandlordTracer)list.get(0)).getLastLoginTime());	
		}
		return date;
	}
}
